import { Context } from 'egg';
import {ErrorModel} from "../resp";
/**
 * 回收袋中间件
*/
export default function recyclingMiddleware() {
    return async (ctx: Context, next) => {
        const {name,phone,code,image,city,province} =  ctx.request.body
        if(!name){
           return ctx.body = new ErrorModel("联系人不能为空",null,-1)
        }
        if (!phone){
            return ctx.body = new ErrorModel("电话不能为空",null,-1)
        }
        if(!province){
            return ctx.body = new ErrorModel("请填写省份",null,-1)
        }
        if(!city){
            return ctx.body = new ErrorModel("请填写市区",null,-1)
        }
        if(!code){
            return ctx.body = new ErrorModel("回收袋编号不能为空",null,-1)
        }
        if(!image){
            return ctx.body = new ErrorModel("请上传图片",null,-1)
        }
    await  next()
    }
}